/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.diagram.classdiagram.commands;

import org.eclipse.gef.commands.Command;
import org.eclipse.uml2.uml.BehavioralFeature;
import org.eclipse.uml2.uml.Parameter;

import com.cea.papyrus.diagram.classdiagram.helper.NodeParameterHelper;

/**
 * Command that creates a parameter.
 * 
 * @author Remi SCHNEKENBURGER
 */

@Deprecated
public class CreateParameterCommand extends Command {
	
	/**
	 * 
	 */
	private String name;
	
	/**
	 * 
	 */
	private BehavioralFeature parent;
	
	/**
	 * 
	 */
	private Parameter parameter;
	
	/**
	 * 
	 */
	private NodeParameterHelper factory;
	
	/**
	 * 
	 * 
	 * @param name 
	 * @param parent 
	 */
	public CreateParameterCommand(String name, BehavioralFeature parent) {
		factory = new NodeParameterHelper();
		setLabel("Create <Parameter>"+name);
		this.name = name;
		this.parent = parent;
	}
	
	/**
	 * 
	 * 
	 * @param parent 
	 */
	public CreateParameterCommand(BehavioralFeature parent) {
		factory = new NodeParameterHelper();
		setLabel("Create <Parameter>"+name);
		this.parent = parent;
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.gef.commands.Command#execute()
	 */
	/**
	 * 
	 */
	@Override
	public void execute() {
		parameter =(Parameter) factory.createUMLElement(parent);
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.gef.commands.Command#redo()
	 */
	/**
	 * 
	 */
	@Override
	public void redo() {
		execute();
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.gef.commands.Command#undo()
	 */
	/**
	 * 
	 */
	@Override
	public void undo() {
		parent.getOwnedParameters().remove(parameter);
	}
}